package agents.interaction;

import game.constants.ReferenceAgent;
import game.constants.ReferenceSpecialFeature;
import interfaces.ActionInterface;
import interfaces.impl.HumanInteraction;

import java.util.ArrayList;

import objects.SpetialFeature;
import objects.WorldObject;
import universe.Universe;
import actions.ActionModifySpetialFeature;
import actions.ActionXYtoMove;
import constants.Constants;
import extra.Position;



public class InteractionMovePlayer extends HumanInteraction{
	
	private ActionXYtoMove actionXYtoMove;
	private Position positionToMove;
	
	SpetialFeature xToMove;

	/*@Override
	public boolean setParameter(String parameter, Universe universe) {
		
		System.out.println("ESTE ES EL PARAMETRO POTION:"+parameter+"PARAMETRO");
		positionToMove=new Position();
		parameter=HumanInteraction.getPositionParameter(parameter,positionToMove);
		System.out.println("esto es en position to move posicion: "+"x "+positionToMove.getX()+" y"+positionToMove.getY());
		System.out.println("ESTE ES EL PARAMETRO POTION1:"+parameter+"PARAMETRO1");

		isActive = true;
		return true;
	}
*/

	@Override
	public void updateChild(WorldObject object, Universe worldI, double time) {
		
	
		System.out.println("XTO MOVE: "+xToMove.getValue()+" X"+object.getPosition().getX());
		
		worldI.desactivateAllHumanInteractions(object);
		
		actionXYtoMove.setSource(object);
		actionXYtoMove.setTarget(object);
		actionXYtoMove.setxToMove(positionToMove.getX());
		actionXYtoMove.setyToMove(positionToMove.getY());
		
		worldI.setAction(actionXYtoMove);
		
		ActionModifySpetialFeature modifyTarget = new ActionModifySpetialFeature();
		modifyTarget.setSource(object);
		modifyTarget.setTarget(object);
		modifyTarget.setFeatureId(ReferenceSpecialFeature.SPETIAL_FEATURE_TARGET_ID_TO_FOLLOW);
		modifyTarget.setValue(Constants.NO_OBJECT_ID);
		worldI.setAction(modifyTarget);
		
		modifyTarget = new ActionModifySpetialFeature();
		modifyTarget.setSource(object);
		modifyTarget.setTarget(object);
		modifyTarget.setFeatureId(ReferenceSpecialFeature.SPETIAL_FEATURE_TARGET_ID_TO_ATTACK);
		modifyTarget.setValue(Constants.NO_OBJECT_ID);
		worldI.setAction(modifyTarget);
		
		System.out.println("Interaction MOve player");
		
		isActive=false;
		
		
	}

	

	@Override
	public void initializeActionList() {
		
		listActions = new ArrayList<ActionInterface>();
		
		actionXYtoMove= new ActionXYtoMove();

		listActions.add(actionXYtoMove);
		
	}

	@Override
	public void initializeSpecialFeatures() {
		xToMove = new SpetialFeature(ReferenceSpecialFeature.SPETIAL_FEATURE_X_TO_MOVE);
		addParameter(xToMove);;
		
	}

	@Override
	public void initializeName() {
		name="Moverse";
		
	}

	@Override
	public void initializeId() {
		this.id=ReferenceAgent.AGENT_HUMAN_INTERACTION_MOVE_PLAYER;
		
	}

	@Override
	public void initializeParametersList() {
		listParameter= new ArrayList();
		
		positionToMove= new Position();
		listParameter.add(positionToMove);
		
	}

	
	

}
